package com.wx.tgp.designpattern.StrategyPattern.Shoppingmall;

import java.util.Scanner;

/**
 * 计算费用的客户端
 */
public class Client {

    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        double price = 0;
        int type;
        while(true){
            System.out.println("请输入商品价格：");
            String str1 = scanner.nextLine();
            try{
                price = Double.parseDouble(str1);
            } catch (Exception e){
                System.out.println("不能输入字符，请重新输入");
                continue;
            }
            break;
        }
        while(true){
            System.out.println("请选择商场优惠模式：1、商品打8折;2、商品满300减100活动");
            String str1 = scanner.nextLine();
            if("1".equals(str1)||"2".equals(str1)){
                type = Integer.parseInt(str1);
            }else{
                continue;
            }
            break;
        }
        FactoryPay factoryPay = new FactoryPay();
        factoryPay.newPaymate(type,price);
        System.out.println(factoryPay.getResult());
    }
}
